import { useEffect, useRef } from 'react';

import * as echarts from 'echarts';

function OneCharts() {
  const echart = useRef<any>();

  useEffect(() => {
    const myChart = echarts.init(echart.current);
    myChart.resize({
      width: 800,
      height: 800,
    });
    window.addEventListener('resize', function () {
      myChart.resize();
    });
    myChart.setOption(
      {
        title: [
          {
            text: 'Tangential Polar Bar Label Position (middle)'
          }
        ],
        polar: {
          radius: [30, '80%']
        },
        angleAxis: {
          max: 4,
          startAngle: 75
        },
        radiusAxis: {
          type: 'category',
          data: ['a', 'b', 'c', 'd']
        },
        tooltip: {},
        series: {
          type: 'bar',
          data: [2, 1.2, 2.4, 3.6],
          coordinateSystem: 'polar',
          label: {
            show: true,
            position: 'middle',
            formatter: '{b}: {c}'
          }
        }
      }
    );
  });
  return (
    <>
      <div
        id="echart"
        ref={echart}
        style={{ width: '500px', height: '400px', backgroundColor: 'rgba(255,255,255,0.3)' }}
      ></div>
    </>
  );
}

export default OneCharts;
